/*------------------------------------------------------------------------------

			Figure A8: Teacher outcome discontinuity plots (t & s level)
							
------------------------------------------------------------------------------*/

global replica_dir="<add path to your working directory>"
global data_dir=	"$replica_dir/data"
global output_dir=	"$replica_dir/output"



/*----------------------------------------------------------------------------*/

**# Teacher-level variables

/*----------------------------------------------------------------------------*/


use "$data_dir/tlvl_fin.dta", clear 


global vars "horas_contrato_tp1  tea_classhrs_tp1 "  

collapse (mean) ${vars} (firstnm) st_ind*, by(rbd year) 

la var st_ind25 "100% vs. 60%"
la var st_ind10 "60% vs. none"

la var horas_contrato_tp1 	"Contract hours"
la var tea_classhrs_tp1  	"Classroom teaching hours"
 


foreach i in 10  25{
local label_st_ind`i': variable label st_ind`i'

	foreach y of global vars{

	local label_`y': variable label `y'
	

	rdplot `y' st_ind`i'  if abs(st_ind`i')<=1.5, h(1.5) graph_options(legend(off) graphregion(color(white)) xtitle("SNED index centered at zero") title("`label_`y'', `label_st_ind`i''") )   xlab(-1.5(0.5)1.5)  binselect(esmv)  kernel(uni) p(2) masspoints(off)
	graph export  "$output_dir/graph_t_`y'_`i'.png" , as(png) replace

	} 
}



/*----------------------------------------------------------------------------*/

**# School-level variables

/*----------------------------------------------------------------------------*/


use "$data_dir/slvl_fin.dta", clear  

global depvars "dropped_tp1 newtea_tp1 exp_tp1 aep10_tp1"  

la var st_ind25 "100% vs. 60%"
la var st_ind10 "60% vs. none"

la var dropped_tp1  "Turnover: Lagged attrition"
la var newtea_tp1    "Turnover: Prop. new teachers"
la var exp_tp1   	"Mean teacher experience"
la var aep10_tp1  	"Prop. AEP certified"
 


foreach i in 10 25{
local label_st_ind`i': variable label st_ind`i'

	foreach y of global depvars{

	local label_`y': variable label `y'
	
	rdplot `y' st_ind`i'  if abs(st_ind`i')<=1.5, h(1.5) graph_options(legend(off) graphregion(color(white)) xtitle("SNED index centered at zero") title("`label_`y'', `label_st_ind`i''") )   xlab(-1.5(0.5)1.5)  binselect(esmv)  kernel(uni) p(2) masspoints(off)
	graph export  "$output_dir/graph_s_`y'_`i'.png" , as(png) replace

	} 
}				
				



